#!/bin/bash

max=5; # 10 max threads
time_shift=0; # 3 seconds
watch_time=120; # max time to wait process

results=[]
test_prg="rake test:units"
#test_prg='echo test'

function start_process() {
 t=$1
 log="./log/mt_test_$t"
 echo "Test: $t"
 echo "Test: $t" > $log
 $test_prg >> $log 2>&1 
 echo "Thread ($t) result: $?" >> $log
}

for i in `seq 1 $max`; do
sleep $time_shift
start_process $i &
done

echo "Wait to finish.."
wait 


echo "Results:"
for t in `seq 1 $max`; do
log="./log/mt_test_$t"
grep "Thread" $log | grep result
done


